package com.dayuanit.dy14.enter.dy14enter1024.controller;

import com.dayuanit.dy14.enter.dy14enter1024.dto.ResponseDTO;
import com.dayuanit.dy14.enter.dy14enter1024.exception.BizException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.ExceptionHandler;

public abstract class BaseController {

    protected static final Logger logger = LoggerFactory.getLogger(BaseController.class);


    @ExceptionHandler(value = BizException.class)
    public ResponseDTO processBizException(BizException be) {
        logger.error(be.getMessage(), be);
        return ResponseDTO.fail(be.getMessage());
    }

    @ExceptionHandler(value = Exception.class)
    public ResponseDTO processException(Exception e) {
        logger.error(e.getMessage(), e);
        return ResponseDTO.fail("系统异常，请联系客服");
    }


}
